package com.rein.study.designpattern.builder._01singleton;

/**
 * 加锁的懒汉模式
 */
public class LockLazySingleton {
    //私有实例
    private static LockLazySingleton instance;

    //构造函数私有化
    private LockLazySingleton() {
    }

    //同步获取实例，实现多线程安全
    public static synchronized LockLazySingleton getInstance() {
        if (instance == null) {
            instance = new LockLazySingleton();
        }
        return instance;
    }
}
